/*
 * Main.fx
 *
 * Created on 20-Jan-2010, 17:29:44
 */
package javafxsample;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.animation.Timeline;
import javafx.animation.Interpolator;
import javafx.scene.effect.Reflection;
import javafx.scene.paint.Stop;
import javafx.scene.paint.Color;
import javafx.scene.paint.LinearGradient;

/**
 * @author Bastien
 */
def labels = ["This", "is", "the", "best", "Hello", "World", "in", "the", "world"];
var currentIndex = -1;
var currentAngle: Number = 0.0;
var currentScale:Number = 0.0;
var currentLabel = Text {
            opacity: bind opacity
            font: Font {
                size: 30;
                name: "Tahoma"
            }
            rotate: bind currentAngle
            scaleX: bind currentScale, scaleY: bind currentScale
            fill: LinearGradient {
                startX: 0.0
                startY: 0.0
                endX: 1.0
                endY: 1.0
                proportional: true
                stops: [
                    Stop {
                        color: Color.RED
                        offset: 0.0
                    },
                    Stop {
                        color: Color.BLUE
                        offset: 1.0
                    },
                ]
            }
            effect: Reflection {
                fraction: 0.75
                topOffset: 0.0
                topOpacity: 0.5
                bottomOpacity: 0.0
            }
            //x: bind Stage.stages[0].scene.width / 2, y: bind Stage.stages[0].scene.height / 2
            x: 50, y: 50
            content: bind labels[currentIndex]
        };
var opacity: Number = 0.0;

Timeline {
    rate: 1
    autoReverse: true
    repeatCount: Timeline.INDEFINITE
    keyFrames: [
        at(0s) {opacity => 0.0; currentIndex => (currentIndex + 1) mod sizeof labels;},
        at(1s) {opacity => 1.0 tween Interpolator.LINEAR;}
    ]
}.play();

Timeline {
    repeatCount: Timeline.INDEFINITE
    keyFrames: [
        at(0s) {currentAngle => 0.0; currentScale => 0.0},
        at(2s) {
                currentAngle => 360.0 tween Interpolator.LINEAR;
                currentScale => 1.0 tween Interpolator.LINEAR;
                }
    ]
}.play();

Stage {
    title: "Appearance effect demo"
    scene: Scene {
        width: 200
        height: 100
        content: [currentLabel]
    }
}
